__all__ = []

import sys
from typing import List, Dict

class Version:
    def __init__(self, name, version, Logger, py_version=None, packages:List[Dict]=None):
        self.name = name
        self.Logger = Logger
        self.version = version
        self.python = py_version
        self.package = packages

    def observe_version(self):
        this_py_version = sys.version.split(' ')[0]
        try:
            if version_eq(this_py_version, self.python) == False:
                self.Logger.error("The Package {} needs python version to be {}. But python {} is running this package".format(self.name, self.python, this_py_version))
        except IndexError:
            self.Logger.error("The Package {} is WARING".format(self.name))
def _version_eq(this_python_version: str, need_python_version: str) -> bool:
    this_python_version = this_python_version.split('.')
    need_python_version = need_python_version.split('.')
    if this_python_version[0] != need_python_version[0]:
        return False
    if this_python_version[1] > need_python_version[1]:
        return False
    if this_python_version[2] > need_python_version[2]:
        return False
    return True


